﻿<%@ Page Title="Create Component" Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true" CodeFile="Create_Comp.aspx.cs" Inherits="admin_Create_Comp" %>

<asp:Content ID="Head" ContentPlaceHolderID="head" runat="Server">
    <link href="../styles/admin.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="top_menu">
        <div id="help_button">
            help
        </div>
                  <div id="logout">
            <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="../Default.aspx"
                OnLoggingOut="LoginStatus1_LoggingOut" />
        </div>
    </div>
    <div id="page_title">
        ADMINISTRATION
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <div id="left_content">
        <div class="menu">
            <ul>
                <li><a href="Home.aspx">Home</a></li>
                <li><a href="Mng_Client.aspx">Manage Clients</a></li>
                <li><a href="Mng_Site.aspx">Manage Sites</a></li>
                <li><a href="Mng_Machine.aspx">Manage Machines</a></li>
                <li><a href="#" class="current">Create New Component</a></li>
                <li><a href="Mng_Report.aspx">Manage Reports</a></li>
                <li><a href="Mng_WO.aspx">Manage Work Order</a></li>
                <li><a href="Mng_FaultsRecom.aspx">Manage Faults Recommendation</a></li>
            </ul>
        </div>
    </div>
    <!-- end of left content -->
    <div id="right_content">
        <div class="content_area">
            <h2>
                Create Component
            </h2>
            <h3>
                <asp:Label ID="machineNameLabel" runat="server" Text="Machine Name" Visible="False"></asp:Label>
            </h3>
            <div class="form_box1">
                <asp:FormView ID="FormViewComponent" runat="server" DataKeyNames="component_id" DataSourceID="ComponentsObjectDataSource"
                    DefaultMode="Insert" OnItemInserted="FormViewComponent_ItemInserted" OnDataBound="FormViewComponent_DataBound">
                    <EditItemTemplate>
                        component_id:
                        <asp:Label ID="component_idLabel1" runat="server" Text='<%# Eval("component_id") %>' />
                        <br />
                        category_id:
                        <asp:TextBox ID="category_idTextBox" runat="server" Text='<%# Bind("category_id") %>' />
                        <br />
                        machine_id:
                        <asp:TextBox ID="machine_idTextBox" runat="server" Text='<%# Bind("machine_id") %>' />
                        <br />
                        componentName:
                        <asp:TextBox ID="componentNameTextBox" runat="server" Text='<%# Bind("componentName") %>' />
                        <br />
                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                            Text="Update" />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
                            CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <table>
                            <asp:PlaceHolder ID="machineNamePlaceHolder" runat="server">
                                <tr>
                                    <td class="label1">
                                        Machine Name:
                                    </td>
                                    <td colspan="2">
                                        <asp:DropDownList ID="machineNameDropDownList" runat="server" DataSourceID="MachineObjectDataSource"
                                            DataTextField="machineName" DataValueField="machine_id" SelectedValue='<%# Bind("machine_id") %>'
                                            CssClass="dropDownList">
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="MachineObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
                                            SelectMethod="GetData" TypeName="DataAccess.i2iPortalTableAdapters.MachinesTableAdapter">
                                        </asp:ObjectDataSource>
                                    </td>
                                </tr>
                            </asp:PlaceHolder>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RequiredFieldValidator ID="componentNameRequiredFieldValidator" runat="server"
                                        ErrorMessage="Component Name is required." ControlToValidate="componentNameTextBox"
                                        ValidationGroup="FormViewComponent">
                                    </asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Component Name:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="componentNameTextBox" runat="server" Text='<%# Bind("componentName") %>'
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Category:
                                </td>
                                <td colspan="2">
                                    <asp:DropDownList ID="CategoryDropDownList" runat="server" DataSourceID="ComponentCategorySqlDataSource"
                                        DataTextField="category_Name" DataValueField="category_id" SelectedValue='<%# Bind("category_id") %>'
                                        CssClass="dropDownList">
                                    </asp:DropDownList>
                                    <asp:SqlDataSource ID="ComponentCategorySqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                        SelectCommand="SELECT * FROM [Category]"></asp:SqlDataSource>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td class="Li_buttonC">
                                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                                        Text="Insert" />
                                </td>
                                <td class="Li_buttonC">
                                    <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                        Text="Cancel" OnClick="InsertCancelButton_Click" />
                                </td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        component_id:
                        <asp:Label ID="component_idLabel" runat="server" Text='<%# Eval("component_id") %>' />
                        <br />
                        category_id:
                        <asp:Label ID="category_idLabel" runat="server" Text='<%# Bind("category_id") %>' />
                        <br />
                        machine_id:
                        <asp:Label ID="machine_idLabel" runat="server" Text='<%# Bind("machine_id") %>' />
                        <br />
                        componentName:
                        <asp:Label ID="componentNameLabel" runat="server" Text='<%# Bind("componentName") %>' />
                        <br />
                        <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                            Text="New" />
                    </ItemTemplate>
                </asp:FormView>
                <asp:ObjectDataSource ID="ComponentsObjectDataSource" runat="server" InsertMethod="Insert"
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataAccess.i2iPortalTableAdapters.ComponentsTableAdapter">
                    <InsertParameters>
                        <asp:Parameter Name="machine_id" Type="Int32" />
                        <asp:Parameter Name="componentName" Type="String" />
                        <asp:Parameter Name="Interval_Id" Type="Int32"/>
                        <asp:Parameter Name="category_id" Type="Int32" />
                    </InsertParameters>
                </asp:ObjectDataSource>
            </div>
        </div>
    </div>
    <!-- end of right content -->
</asp:Content>
